package com.sys.service.impl;

import java.util.HashMap;
import java.util.List;
import java.util.Map;


import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.sys.dao.TeacherDao;
import com.sys.entity.Teacher;
import com.sys.service.TeacherService;

@Service
public class TeacherServiceImpl implements TeacherService {
	@Autowired
	private TeacherDao TeacherDao;

	@Override
	public Map<String, Object> getAllTeacher(String tname, String phone, Integer del, Integer page, Integer limit) {
		Map<String, Object> prams = new HashMap<String, Object>();
		prams.put("tname", tname);
		prams.put("phone", phone);
		prams.put("del", del);
		page = (page - 1) * limit;
		prams.put("page", page);
		prams.put("limit", limit);
		List<Teacher> list = TeacherDao.getAllTeacher(prams);
		int total = TeacherDao.getAllTeacherCount(prams);
		Map<String, Object> map = new HashMap<String, Object>();
		map.put("list", list);
		map.put("total", total);
		return map;
	}

	@Override
	public int addTeacher(Teacher teacher) {
		int len = TeacherDao.addTeacher(teacher);
		return len;
	}

	@Override
	public int updateTeacher(Teacher teacher) {
		int len = TeacherDao.updateTeacher(teacher);
		return len;
	}

	@Override
	public int deleteTeacher(Integer tid) {
		int len = TeacherDao.deleteTeacher(tid);
		return len;
	}

}
